<?php $this->headTitle('Section Administration'); ?>
<script type="text/javascript">
	function changeStatus(id) {
		$.ajax({
			data: { 'id': id },
			dataType: 'json',
			error: function(rqs, status, error) {
				alert('There was a problem changing the status of the plugin.');
			},
			success: function(rsp) {
				if(rsp.success == 1) {
					$('#status_' + id).html((rsp.status == 0 ? 'Inactive' : 'Active'));
				} else {
					alert(rsp.message);
				}
			},
			type: 'GET',
			url: '/admin/modules/changestatus/'
		});
	}
	
	function installPlugin(name)
	{
		$.ajax({
			data: { 'name' : name },
			dataType: 'json',
			error: function(rqs, status, error) {
				alert('There was a problem calling the installer for the ' + name + ' plugin.');
			},
			success: function(rsp) {
				if(rsp.status) {
					alert('Plugin ' + name + ' has been installed.');
					window.location = '/admin/modules';
				} else {
					alert('There was a problem installing ' + name);
				}
			},
			type: 'GET',
			url: '/admin/modules/install/'
		});
	}
	
	function uninstallPlugin(name)
	{
		$.ajax({
			data: { 'name' : name },
			dataType: 'json',
			error: function(rqs, status, error) {
				alert('There was a problem calling the uninstaller for the ' + name + ' plugin.');
			},
			success: function(rsp) {
				if(rsp.status) {
					alert('Plugin ' + name + ' has been uninstalled.');
					window.location = '/admin/modules';
				} else {
					alert('There was a problem uninstalling ' + name + '. There error was:\n' + rsp.message);
				}
			},
			type: 'GET',
			url: '/admin/modules/uninstall/'
		});
	}
	
	$(document).ready(function() {
		$('.stripped tr:even').addClass('evenRow');
	});
</script>

<h1>Section Administration</h1>

<h2>Installed Sections</h2>

<table class="stripped" cellspacing="0" width="100%">
	<thead>
		<tr>
			<th>Name</th>
			<th>Description</th>
			<th>Status</th>
			<th>Uninstall</th>
		</tr>
	</thead>
	<tbody>
		<?php echo $this->partialLoop('modules/_partials/installedModules.phtml', $this->installedModules);?>
	</tbody>
</table>

<h2>Uninstalled Sections</h2>

<table class="stripped" cellspacing="0" width="100%">
	<thead>
		<tr>
			<th>Name</th>
			<th>Install</th>
		</tr>
	</thead>
	<tbody>
		<?php echo $this->partialLoop('modules/_partials/uninstalledModules.phtml', $this->uninstalledModules);?>
	</tbody>
</table>
